package methodminxin

//通过mimix 将Friend类注入到Dog类中
Dog.mixin Friend
def dog = new Dog(name:"大黄")
dog.listening()
//通过metaclass可以注入到实例中
def cat = new Cat(name: "喵喵")
cat.metaClass.mixin Friend
cat.listening()
def cat1 = new Cat(name: "咪咪")
// cat1.listening() 会报错